<?php
	require_once('../engine/include.php');
	
	estaLogado('../login.php', 1);
	
	$query = "SELECT * FROM usuario WHERE id=".$_SESSION['id_logado'];
	$result = mysql_query($query);
	
	$usuario_logado = mysql_fetch_assoc($result);
	
	//Criei a query
	$sql = "SELECT * FROM usuario u;";
	// Executei a query
	$result = mysql_query($sql);
	// Recuperei a primeira linha dos resultados
	$usuarios = array();
	while($row = mysql_fetch_assoc($result))
	{
		$usuarios[] = $row;
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		
		<meta http-equiv="content-language" content="pt-br" />
		<meta name="author" content="ejcm" />
		<meta name="keywords" content="ejcm" /> <!-- Coloque todas as keywords que devam aparecer -->
		
		<title>Gerenciar Usuário</title>
	</head>
	<body>
		<div id="principal">
		<?php require('../layoutUp.php');?>
		<?php imprimeSession();?>
		
			<span style="font-size: 20px; color:blue;">
				<?php
					$nome = $usuario_logado['nome']; 
					echo "SEJA BEM VINDO $nome<br />";
				?>
			</span>
			<br />
			<table border="1">
				<thead>
					<tr>
						<th>Nome</th>
						<th>Login</th>
						<th>Email</th>
						<th colspan="2">Opções</th>
					</tr>
				</thead>
				<tbody>
					<?php foreach($usuarios as $usuario){?>
						<tr>
							<td><?php echo $usuario['nome'];?></td>
							<td><?php echo $usuario['login'];?></td>
							<td><?php echo $usuario['email'];?></td>
							
		<td>
		<a 
		href="<?php echo "./alterar.php?id=".$usuario['id']; ?>">
		Alterar
		</a>
		</td>
		<td>
		<a
		href="<?php echo "./excluir.php?id=".$usuario['id']; ?>"
		onclick="javascript: return confirm('Tem certeza que deseja excluir <?php echo $usuario['nome'];?>');"
		>Excluir</a></td>
						</tr>
						
					<?php }?>
				</tbody>
			</table>
			<p>
				<a href="./inserir.php">Inserir</a>
			</p>
		<?php require('../layoutDown.php');?>
		</div>
	</body>
</html>
